草庐IT

javascript - react 路由器 this.props.location

全部标签

ruby-on-rails - Geocoding API 的响应不是有效的 JSON。和 request.location = nil

ifRails.env.development?@current_location_geo=Geocoder.search(request.remote_ip).firstelse@current_location_geo=request.locationendif!@current_location_geo.nil?&&@current_location_geo.ip=="127.0.0.1"@departure_currency_code="AUD"@departure_currency_name=["AustralianDollar(AUD$)","AUD"]else@count

ruby-on-rails - Rails 4.0 中的路由、路径助手和 STI

这让我发疯!我有两个模型Lion和Cheetah。两者都继承自Wildcat。classWildcat这里用的是STI。它们都通过ControllerWildcatsController进行处理。在那里,我有一个before_filer从params[:type]和所有其他东西中获取wildcat的type以使用正确的类.在我的routes.rb中,我创建了以下路线:resources:lions,controller:'wildcats',type:'Lion'resources:cheetahs,controller:'wildcats',type:'Cheetah'如果我现在想使

ruby-on-rails - 如何为新模板添加路由?

我是Ruby和Rails的新手,对为新模板渲染和添加路由有点困惑。我关注link_to标签:current_state,:class=>'btnbtn-primary'%>在哪里simulation是Controller的名称,action是SimulationController中方法的名称.我在我的routes.rb中添加了这个resources:simulations,except:[:edit]resources:simulationsdocollectiondoget'current_state'post'current_state'endend在我的SimulationCo

ruby-on-rails - 从 url 字符串中查找路由路径

我想知道api请求的路由是什么比方说api_v1_user_session_path是/api/v1/users/sign_inurl的路径如果请求来自/api/v1/users/sign_in我如何找出路由。在这种情况下,它应该是api_v1_user_session_path我尝试了下面的语句,但它提供了Controller和操作,但没有提供路由。Rails.application.routes.recognize_path('/api/v1/users/sign_in')=>{:controller=>"api/v1/sessions",:action=>"new"}有没有这样的

ruby-on-rails - 在 Rails 中动态重新加载路由是个坏主意吗?

我有一个正在编写的应用程序,我允许管理员为页面、类别等添加别名,我想根据别名使用不同的Controller/操作(不重定向,我'我发现render实际上并没有调用该方法。我只是渲染了模板)。我已经尝试了捕获所有路由,但我并不热衷于引发和捕获每次都会抛出的DoubleRender异常。我想出的解决方案是在服务器启动时动态生成路由,并在创建/更新/销毁别名时使用别名模型的回调重新加载路由。这是我的routes.rb中的代码:Alias.find(:all).eachdo|alias_to_add|map.connectalias_to_add.name,:controller=>alias

ruby - 使用 Sinatra 创建路由以仅接受特定的内容类型

我正在尝试使用Sinatra创建一条仅接受带有Content-type:application/json的POST的路由,但没有成功。我的做法如下:post'/dogs',:provides=>:jsondo#returnshereajsonresponseend使用curl进行测试,我发现:provides=>:json配置路由以响应Content-Type:application/json。没错,因为我还想用JSON消息响应POST请求,但我真的需要这条路由只用Content-Type:application/json响应POST请求,而不是,例如,对其他人(例如Content-T

ruby-on-rails - 我如何在 Rails 3 插件中测试路由?

我尝试使用推荐的方式(来自Rails指南)来测试插件中生成的路由,但测试一直失败。奇怪的是,如果我在创建路由后重新加载路由(或者我认为如此),测试会失败,但如果我让测试通过一次(例如使用自动测试),那么该路由会在后续尝试中被识别.代码如下:describe"namedroutereport_with_last_name_smith_path"dobefore:alldoReports::Application.routes.drawdomatch"/report_some_report_for_us"=>"report#report_some_report_for_us",:as=>:

ruby - 为 Rails 3 插件生成测试路由时出错?

我正在尝试为修改一些标准Rails助手的插件“foobar”开发测试。在vendor/plugins/foobar/test/foobar_test.rb中,我有以下内容:#createthetestmodelclassThing'index')}enddefdestroy@thing=Thing.find(params[:id])@thing.destroyformat.html{render(:file=>'index')}endend#confirmthatthetestenvironmentisworkingcorrectlyclassThingsTest[:index,:de

ruby - JRuby cannot switch to 1.6.2 for this interpreter error rvm

我正在尝试在UbuntuLinux上使用RVM配置JRuby。我已成功安装RVM,但在尝试安装Jruby时,出现以下错误:dlitwak@ubuntu:~$rvminstalljruby-1.6.0jruby-1.6.0-#fetchingjruby-1.6.0-#extractedto/home/dlitwak/.rvm/src/jruby-1.6.0(alreadyextracted)BuildingNailgunjruby-1.6.0-#installingto/home/dlitwak/.rvm/rubies/jruby-1.6.0**ERROR:Cannotswitchto1

ruby-on-rails - 尽管安装了 therubyracer 和 nodejs,但找不到 JavaScript 运行时

我尝试在CentOS5上运行Rails应用程序并不断收到thiserror:CouldnotfindaJavaScriptruntime.Seehttps://github.com/sstephenson/execjsforalistofavailableruntimes.(ExecJS::RuntimeUnavailable)我同时安装了NodeJS(v0.8.15)和therubyracer(libv8)。这是我的gemlist:***LOCALGEMS***actionmailer(3.2.9,3.2.8)actionpack(3.2.9,3.2.8)activemodel(3.